package com.ruoyi.pingan.fymodule.account.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.pingan.fymodule.account.entity.SxoSafetyLog;
import com.ruoyi.pingan.fymodule.account.mapper.SxoSafetyLogMapper;
import com.ruoyi.pingan.fymodule.account.service.ISxoSafetyLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


/**
 * 调平安接口日志 业务层实现
 *
 * @author wangy
 * @since 2025-06-11
 */
@Slf4j
@Service
public class SxoSafetyLogServiceImpl extends ServiceImpl<SxoSafetyLogMapper, SxoSafetyLog> implements ISxoSafetyLogService {


    @Override
    public String saveSafetyLog(String id, String busId, String apiName, String parameter) {
        SxoSafetyLog sxoSafetyLog = new SxoSafetyLog();
        if (StrUtil.isNotEmpty(id)) {
            sxoSafetyLog.setId(id);
        }
        if (StrUtil.isNotEmpty(busId)) {
            sxoSafetyLog.setBusId(busId);
        }
        sxoSafetyLog.setApiName(apiName);
        sxoSafetyLog.setParameter(parameter);
        sxoSafetyLog.setAddTime(DateUtil.now());
        sxoSafetyLog.setUpdTime(DateUtil.now());
        this.save(sxoSafetyLog);
        return sxoSafetyLog.getId();
    }

    @Override
    public void updateSafetyLog(String id, String results) {
        SxoSafetyLog sxoSafetyLog = new SxoSafetyLog();
        sxoSafetyLog.setId(id);
        sxoSafetyLog.setUpdTime(DateUtil.now());
        sxoSafetyLog.setResults(results);
        this.updateById(sxoSafetyLog);
    }
}